use actix_web::{HttpRequest, HttpResponse};
use super::ApiResult;
use actix_web::body::Body;
use failure::Fail;

#[derive(Fail, Debug)]
#[fail(display = "Login failed, id: {}, username: {}", user_id, user_name)]
struct LoginError {
    user_id: u32,
    user_name: String,
}

fn do_login() -> Result<(), LoginError> {
    Err(LoginError {
        user_id: 10,
        user_name: "hehele".to_owned(),
    })
}

pub(crate) fn login<'a>(_: ()) -> ApiResult<&'a str> {
    ApiResult::with(|| {
        let _ = do_login()?;
        Ok("")
    })
}
